package com.buyi.easyhome.widget

import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.content.Intent


/**
 * Implementation of App Widget functionality.
 */
class ClockAppWidget4x5 : AppWidgetProvider() {
    override fun onUpdate(
        context: Context,
        appWidgetManager: AppWidgetManager,
        appWidgetIds: IntArray
    ) {
        // There may be multiple widgets active, so update all of them
        updateAppWidget(context, appWidgetManager, ClockAppWidget4x5::class.java)
    }

    override fun onReceive(context: Context?, intent: Intent?) {
        super.onReceive(context, intent)
        if (intent != null) {
            if (AppWidgetManager.ACTION_APPWIDGET_UPDATE == intent.action) {
                if (context != null) {
                    // 获取 AppWidgetManager 实例
                    val appWidgetManager = AppWidgetManager.getInstance(context)
                    updateAppWidget(context, appWidgetManager, ClockAppWidget4x5::class.java)
                }
            }
        }
    }
}
